<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>增加学生</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
</head>
<body>

<div id="app">

    <fieldset style="width: 500px;margin: 80px auto;padding: 30px">
        <legend>添加学生信息</legend>
        <span v-if="isOk == 0">
                <span class="label label-danger">添加失败</span>
            </span>
        <span v-else-if="isOk == 1">
                <span class="label label-success">添加成功</span>
            </span>
        <div class="form-group">
            <label>id</label>
            <input v-model="stuInfo.id" class="form-control" placeholder="请输入您的id">
        </div>

        <div class="form-group">
            <label>姓名</label>
            <input v-model="stuInfo.name" class="form-control" placeholder="请输入您的姓名">
        </div>
        <div class="form-group">
            <label>年龄</label>
            <input v-model="stuInfo.age" class="form-control" placeholder="请输入您的年龄">
        </div>
        <div class="form-group">
            <label>地址</label>
            <input v-model="stuInfo.address" class="form-control" placeholder="请输入您的地址">
        </div>

        <button type="submit" class="btn btn-default"  @click="addStu()">添加</button>
        <a href="/test1/student/selectStudent.html" class="btn btn-default">返回</a>
    </fieldset>

</div>

<script>
    var haha = new Vue({
        el:"#app",
        data:{

            stuInfo:{},
            isOk:-1
        },
        methods:{
            addStu:function () {
                $.post("/test1/stu/addStu",haha.stuInfo,function (backData) {
                    haha.isOk = backData.data;
                });
            }
        }
    });


</script>


</body>
</html>